Skip to content

#16 use the request path in the exception #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 21, 2022

Conversation

dannystaple
Copy link
Contributor

Fixes #16.
Output looks like:

Traceback (most recent call last):
  File "code.py", line 1, in <module>
  File "counting.py", line 23, in <module>
  File "robot_wifi.py", line 52, in start_wifi_server
  File "adafruit_esp32spi/adafruit_esp32spi_wsgiserver.py", line 105, in update_poll
  File "/lib/adafruit_wsgi/wsgi_app.py", line 74, in __call__
RuntimeError: Proper HTTP response return not given for request handler '/count'

@tekktrik
Copy link
Member

Good solution! Want to update the accompanying text to something more about the "path" than the "request handler"?
Actually I think "request handler for path" would be enough information to indicate that the issue is for the actual function while referencing it's path.

@tekktrik tekktrik self-requested a review May 11, 2022 01:32
Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feedback from above, but now in review format so I can hit the "Request changes" button 😄

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change because the text seems to be broken up upon testing

"Proper HTTP response return not given for request handler '{}'".format(
route["func"].__name__
)
f"Proper HTTP response return not given for request handler for path \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this out, and it seems this will be raised and catch the tabs as follows:

RuntimeError: Proper HTTP response return not given for request handler for path         'some/path/'

Try this out, I think this should both appease pylint and keep the words together:

    "Proper HTTP response return not given for request handler for path "
    f"'{request.path}'"

Note the space after path in the first line!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be better there. It didn't need to be f-stringed, as it is already typed as a string, so a simple concatenation should be good enough

route["func"].__name__
)
"Proper HTTP response not returned by request handler for path "
+ "'{request.path}'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the f is missing for the f-string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facepalm. Fixed it.

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! Looks good to me!

@tekktrik tekktrik merged commit ca4bc23 into adafruit:main May 21, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 22, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_WSGI to 1.1.10 from 1.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_WSGI#17 from dannystaple/16/use-request-path-in-exception
  > Patch .pre-commit-config.yaml
  > change discord badge
  > Patch: Replaced discord badge image
  > Update .gitignore
  > Update Black to latest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception handling tries to use function.__name__
3 participants